import './public-path';
import './assets/main.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper';
import App from './App.vue'
import router from './router'

let app
//判断是否为乾坤环境
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
  createApp(App).use(router).use(createPinia()).mount('#app');
} else {
  renderWithQiankun({
    mount(props) {
      app = createApp(App);
      app.use(router).use(createPinia()).mount(props.container.querySelector('#app'));
    },
    bootstrap() {
      console.log('vue app bootstrap');
    },
    update() {
      console.log('vue app update');
    },
    unmount() {
      console.log('vue app unmount');
      app?.unmount();
    }
  });
}

// app.use(createPinia())
// app.use(router)

// app.mount('#app')

// function render(props = {}) {
//   const { container } = props
//   app.mount(container ? container.querySelector("#vueApp3") : "#app")
// }
// if (!window.POWERED_BY_QIANKUN__) {
//   render()
// }
// export async function bootstrap() {
//   console.log("[vue] vue app bootstraped")
// }
// export async function mount(props) {
//   console.log("[vue] props from main framework", props)
//   render(props)
// }
// export async function unmount() {
//   app.unmount()
// }
